<?php
echo "Student list:<br>";
include('Student.php');

$students = array();

// 1. 更新第一个学生（John Doe）：构造函数新增status参数（Junior，参考文档示例）
$first = new Student("Doe", "John", "Junior");
$first->add_email('home', 'john@doe.com');
$first->add_email('work', 'jdoe@mcdonalds.com');
$first->add_grade(65);
$first->add_grade(75);
$first->add_grade(55);
$students['j123'] = $first;

// 2. 更新第二个学生（Albert Einstein）：构造函数新增status参数（Freshman，参考文档示例）
$second = new Student("Einstein", "Albert", "Freshman");
$second->add_email('home', 'albert@braniacs.com');
$second->add_email('work1', 'a_einstein@bcit.ca');
$second->add_email('work2', 'albert@physics.mit.edu');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;

// 3. 更新第三个学生（Xavier De Paun）：构造函数新增status参数（示例设为Senior）
$third = new Student("wenhua", "zhao", "China");
$third->add_email('home', 'zhaowenhua@depauw.ca');
$third->add_grade(60);
$third->add_grade(70);
$third->add_grade(72.5);
$students['x789'] = $third;

// 4. 新增第四个学生（Bill Gates，参考文档示例）：含status（Junior）、邮箱、成绩
$fourth = new Student("Gates", "Bill", "Junior");
$fourth->add_email('home', 'gates@microsoft.com'); // 文档示例邮箱修正（原文档"gates8microsoft.com"应为笔误）
$fourth->add_grade(95);
$fourth->add_grade(98);
$fourth->add_grade(100); // 平均成绩97.67，文档示例"98.5"可根据实际成绩调整
$students['b012'] = $fourth;

// 保留第五次提交的排序逻辑：按键名排序
ksort($students);

// 遍历输出所有4个学生信息（含年级）
foreach ($students as $student) {
    echo $student->toString();
}